﻿using UnityEngine;
using System.Collections;

public class Spawner : MonoBehaviour {
	
	
	public GameObject blockPrefab;
	GameObject time;
	float timer = 25f;
	private float BlockSpawnTimer;
	public float BlockFrequencyInSeconds;

	// Use this for initialization
	void Start () {
	}
	public void SpawnObject(GameObject prefab)
	{
		GameObject block = (GameObject)Instantiate(prefab);
		block.GetComponent<Block>().parent = this.transform.parent.parent;

	}
	public void AddTime(float plusTime)
	{
		timer += plusTime;
	}
	// Update is called once per frame
	void Update () {
		BlockSpawnTimer += 1f/60f;
		timer -= 1f/60f;
		if(BlockSpawnTimer > BlockFrequencyInSeconds)
		{	SpawnObject(blockPrefab); BlockSpawnTimer = 0.0f; }

	}
}